package API;

import java.awt.*;
import java.util.ArrayList;

public class ArrayListOperator {
    public static void main(String[] args) {
        //1：创建ArrayList对象
        System.out.println("1------------------------");
        ArrayList<String> list=new ArrayList<String>();
        list.add("我是大帅比");
        list.add("呜呼呼呼");
        //list.add(345);
        list.add("adsaf");
        System.out.println(list);

        //2:指定处添加
        System.out.println("2------------------------");
        list.add(2,"niuniuniu");
        list.add(3,"呜呼呼呼");
        System.out.println(list);

        //3:去集合某个位置的值
        System.out.println("3------------------------");
        System.out.println(list.get(1));

        //4:获得集合大小
        System.out.println("4------------------------");
        System.out.println(list.size());

        //5:删除某个值并返回该值
        System.out.println("5------------------------");
        System.out.println(list.remove(4));
        System.out.println(list);

        //6:删除某个值，成功返回true
        System.out.println("6------------------------");
        System.out.println(list.remove("我是大帅比"));
        System.out.println(list);

        //默认删除第一个出现的
        System.out.println("------------------------");
        System.out.println(list.remove("呜呼呼呼"));
        System.out.println(list);

        //7:修改特定位置的值，并返回修改后的值
        System.out.println("7------------------------");
        System.out.println(list.set(1,"啊哈哈哈"));
        System.out.println(list);
    }
}
